Clojure Golf: combinations (2)

unsorted — cgrand, 19 October 2008 @ 9 h 41 min
(defn combinations [& cs]
  (reduce #(for [v %1 i %2] (conj v i)) [[]] cs))

Clojure Golf: combinations

unsorted — cgrand, 18 October 2008 @ 15 h 53 min
(defn combinations [& cs]
  (reduce (fn [vs c] 
           (mapcat #(map conj vs (repeat %)) c))
          [[]] cs))
(c) 2024 Clojure and me | powered by WordPress with Barecity